package com.demo.accessibilitykeeper;

import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

/**
 * 设备管理员接收器
 * 用于处理设备管理员权限的激活和停用
 */
public class AppDeviceAdminReceiver extends DeviceAdminReceiver {
    
    private static final String TAG = "AppDeviceAdminReceiver";
    
    @Override
    public void onEnabled(Context context, Intent intent) {
        super.onEnabled(context, intent);
        Log.i(TAG, "✅ DEVICE_ADMIN_ENABLED - Device admin permission enabled");
        Toast.makeText(context, "设备管理员权限已激活", Toast.LENGTH_SHORT).show();
    }
    
    @Override
    public void onDisabled(Context context, Intent intent) {
        super.onDisabled(context, intent);
        Log.i(TAG, "❌ DEVICE_ADMIN_DISABLED - Device admin permission disabled");
        Toast.makeText(context, "设备管理员权限已停用", Toast.LENGTH_SHORT).show();
    }
    
    @Override
    public CharSequence onDisableRequested(Context context, Intent intent) {
        Log.w(TAG, "⚠️ DEVICE_ADMIN_DISABLE_REQUESTED - User requested to disable device admin");
        return "停用设备管理员权限将导致设备锁定功能无法使用";
    }
}

